package com.koron.operation.classes.schedule.controller;

import com.koron.bean.base.Response;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.operation.classes.schedule.bean.po.ClassesStaff;
import com.koron.operation.classes.schedule.service.ClassesStaffService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author jzp
 * @since 2022/3/23
 */
@Api(tags = "人员信息接口")
@RestController
@RequestMapping("staff")
public class StaffController {

    @Autowired
    private ClassesStaffService staffService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation(value = "根据id查询")
    @GetMapping
    public Response<ClassesStaff> selectOne(@RequestParam String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), staffService, "getById", ClassesStaff.class, id));
    }

    @ApiOperation(value = "确认签名")
    @PostMapping("sign")
    public Response sign(@RequestParam String id) {
        ADOConnection.runTask(getCurrDs(), staffService, "sign", Boolean.class, id);
        return Response.ok();
    }

    @ApiOperation(value = "取消签名")
    @PostMapping("unSign")
    public Response unSign(@RequestParam String id) {
        ADOConnection.runTask(getCurrDs(), staffService, "unSign", Boolean.class, id);
        return Response.ok();
    }

    @ApiOperation(value = "根据班次id查询人员信息")
    @GetMapping("list")
    public Response<List<ClassesStaff>> listByShiftId(@RequestParam String shiftId) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), staffService, "listByShiftId", List.class, shiftId));
    }

}
